<template>
	<view>
		<scroll-view   scroll-y="true" @scrolltolower="onScroll" style="height: 90vh;width: 100%;"  @scrolltoupper="onScrollTop">
			<uv-list v-for="item in list" v-if="list.length > 0">
			    <uv-list-item :title="item.shopName" 
				:thumb="baseUrl+item.shopCover" 
				thumb-size="lg" clickable @click="goShop(item.shopId)"></uv-list-item>
			</uv-list>
			<uv-empty v-else></uv-empty>
		</scroll-view>
	</view>
</template>

<script setup lang="ts">
	import {baseUrl} from '@/api/request'
	import { ref } from 'vue';
	import {pagecareShop} from '@/api/care-shop.ts'
	import { onShow } from '@dcloudio/uni-app';
	const goShop=(id)=>{
		uni.navigateTo({
			url:'/pages/shop/index?id='+id
		})
	}
	const list=ref([])
	const total=ref(0)
	const queryParam=ref({
		page:1,
		limit:10
	})
	onShow(()=>{
		list.value=[]
		total.value=0
		getList()
	})
	const getList=()=>{
		pagecareShop(queryParam.value).then(res=>{
			if(queryParam.value.page==1){
				list.value=list.value.concat(res.data.list) 
			}else{
				list.value=res.data.list
			}
			total.value=res.data.total
		})
	}
	const onScroll=()=>{
		queryParam.value.page++;
		getList()
	}
	const onScrollTop=()=>{
		queryParam.value.page=1;
		getList()
	}
</script>

<style>
</style>